<template>
    <div class="center_div">
        <el-table :data="allDisk" v-loading="tableLoading" element-loading-text="Loading">
            <el-table-column prop="employeename" label="上传者" min-width="90"></el-table-column>
            <el-table-column prop="thetime" label="上传时间" min-width="90"></el-table-column>
            <el-table-column prop="fatherpath" label="存储位置" min-width="90"></el-table-column>
            <el-table-column prop="filerealname" label="文件名" min-width="90"></el-table-column>
            <el-table-column label="操作" min-width="100" align="center">
                <template slot-scope="scope">
                    <el-button type="danger" @click="delDisk(scope.row.fileid)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                activeName: '共享平台',
                allDisk: [
                    {fileid: 1,employeename: '王小五',employeeid: 1,thetime: '2020-01-02 11:11:11',filerealname: 'myself.png'},
                    {fileid: 2,employeename: '李大二',employeeid: 2,thetime: '2020-01-02 11:11:11',filerealname: 'myself.png'}
                ],
                tableLoading: false
            }
        },
        created() {
            this.fetchDisk()
        },
        methods: {
            async fetchDisk(){
                this.tableLoading = true
                let {code ,data ,msg} = await this.$post('/managerboss/filedelete')
                if(code === 200) {
                    this.allDisk = data
                    this.$formatDateForObjectInArray(this,['allDisk'],['thetime'])

                }else {
                    this.$message.error(msg)
                }
                this.tableLoading = false
            },
            delDisk(id) {
                console.log(id)
                this.delDiskFile(id)
            },
            async delDiskFile(id){
                let {code ,data ,msg} = await this.$post('/managerboss/filedeletedo',{
                    data: {id: id}
                })
                if(code === 200) {
                    this.allDisk = data
                }else {
                    this.$message.error(msg)
                }
            },
        }

    }
</script>

<style>
    .center_div{
        width: 90%;
        margin:0 auto;
        margin-bottom: 50px;
    }
</style>